package com.ikingtech.platform.service.system.division.service;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ikingtech.platform.service.system.division.entity.DivisionDO;
import com.ikingtech.platform.service.system.division.mapper.DivisionMapper;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author tie yan
 */
@Slf4j
@Service
@RequiredArgsConstructor
public class DivisionService extends ServiceImpl<DivisionMapper, DivisionDO> {

    public List<DivisionDO> listByLevel(List<String> levels) {
        return this.list(Wrappers.<DivisionDO>lambdaQuery()
                .in(DivisionDO::getDivisionLevel, levels));
    }

    public List<DivisionDO> listByParentId(String parentId) {
        return this.list(Wrappers.<DivisionDO>lambdaQuery().eq(DivisionDO::getParentId, parentId));
    }

    public List<DivisionDO> listByParentNo(String parentNo) {
        return this.list(Wrappers.<DivisionDO>lambdaQuery().eq(DivisionDO::getParentNo, parentNo));
    }
}
